home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
programming
/
other
/
gui4cli
/
dir
/
dir.gc
< prev
next >
Wrap
Text File
|
1999-05-14
|
8KB
|
388 lines
G4C
; This is a Full blown File Manager.
; I know it's difficult to follow specially since it consists
; of many GUIs which open-close on their own, but.. hey, it's
; a tough world out there..
; The main variable used is "lv_file", which is the name of the
; variable where both listviews will store the files selected.
; Get the full archive of Gui4Cli (Aminet:Dev/Gui/Gui4Cli.lha),
; read the guide and construct the file manager of your dreams!
WINBIG 150 11 220 229 Devices
WinType 11110001
varpath ''
nofontsense
xOnLoad
fm_mode = 1
setgad Dir.gc 2 HIDE ; hide the gadgets of the
setgad Dir.gc 201/210 HIDE
setgad Dir.gc 10 HIDE
guiopen Dir.gc
guiload :Dir.g ; load the helper guis
guiload :dir.g2
guiload :dir.popfav
guiload guis:tools/Prefs/players ; the default viewers
favmode.1 = 0
favmode.2 = 0
xonreload
guiopen dir.gc
xonquit
guiquit Dir.g ; quit our other guis also
guiquit Dir.g2
guiquit Dir.g3
guiquit dir.g4
guiquit dir.pop2
guiquit cli.gc
guiquit dir.prot
guiquit dir.user
guiquit dir.popfav
guiquit getfiletype
guiquit viewfile ; it will quit viewfile2
xOnOpen
SetGad dir.gc 20 OFF
xOnClose
SetGad dir.gc 20 ON
xAppIcon 0 0 :dir.gc DIR.gc *lv_app OFF
GadID 20
GuiOpen dir.gc
GuiScreen dir.gc FRONT
if $*lv_app > " "
gosub dir.gc appdir
endif
xAppWindow *lv_app ; The FM is also an AppWindow
gosub dir.gc appdir ; going to the dir of the icon..
xroutine appdir ; cd to the appitem's dir
ifexists DIR $*lv_app ; if it's a dir,vol,dev or asn
orifexists DOS $*lv_app
dir = $*lv_app
file = ''
elseifexists file $*lv_app ; if it's a file
extract *lv_app PATH dir
extract *lv_app FILE file
endif
lvuse dir.gc 1
lvdir #$dir
lvfind $file
setwintitle dir.gc '$dir'
delvar *lv_app
xOnRMB
if $favmode.1 > 0
favid = 1
guiopen dir.popfav
elseif $favmode.2 > 0
favid = 2
guiopen dir.popfav
else
guiopen Dir.g ; This has the copy, delete etc functions
endif
; ===================================================================
; The directory listviews
; ===================================================================
; Note they both have Hooks to display the current dir to the user.
;---------> the left side
XLISTVIEW 0 0 204 228 "" lv_file "" 10 DIR
gadid 1
lvdirhook 1
GadFont #mono 8 000 ; CHANGE THIS TO THE FONT YOU LIKE!
; LVColors 2 1 3 2 ; uncomment this line for genlocking
; attr dirstyle 2031 ; uncomment for 3D dirs
if $favmode.1 = 1
cutvar lv_file cut word -1 lv_file
extract lv_file clean lv_file
if $lv_file == TITLE
stop
endif
favmode.1 = 0
lvmode DIR
lvdir #$lv_file
setwintitle Dir.gc '$lv_file'
else
guiopen Dir.g2
endif
xLVDirHook 1
setwintitle Dir.gc '$$lv.dir' ; show it in the wintitle
;----------> the right side
XLISTVIEW 220 16 205 212 "" lv_file "" 10 DIR
gadid 2
lvdirhook 2
GadFont #mono 8 000 ; CHANGE THIS TO THE FONT YOU LIKE!
; LVColors 2 1 3 2 ; uncomment this line for genlocking
if $favmode.2 = 1
cutvar lv_file cut word -1 lv_file
extract lv_file clean lv_file
if $lv_file == TITLE
stop
endif
favmode.2 = 0
lvmode DIR
lvdir #$lv_file
update Dir.gc 10 $lv_file
else
guiopen Dir.g2
endif
xLVDirHook 2
update Dir.gc 10 $$lv.dir ; show it in xTextIn gadget below
XTEXTIN 220 0 204 16 "" lvdir2 "" 140
gadid 10
GadFont topaz.font 8 000
lvuse dir.gc 2
LVDir #$lvdir2 ; you can change the dir from here
; ===================================================================
; Disk in/out events
; ===================================================================
xondiskin
gosub dir.gc diskrefresh
xondiskout
gosub dir.gc diskrefresh
xroutine diskrefresh
lvuse dir.gc 1
if $$lv.dir = '' ; refresh if it's a device list
lvdir disks
endif
lvuse dir.gc 2
if $$lv.dir = ''
lvdir disks
endif
; ===================================================================
; Listview control buttons
; ===================================================================
;--------> for the left side (source)
XBUTTON 205 0 14 13 P
GadID 101
lvuse dir.gc 1
LVDir parent
lv_dir1 = $$LV_DIR
setwintitle Dir.gc '$$lv.dir'
XBUTTON 205 13 14 13 R
GadID 102
lvuse dir.gc 1
LVDir Root
lv_dir1 = $$LV_DIR
setwintitle Dir.gc '$$lv.dir'
XBUTTON 205 26 14 13 D
GadID 103
lvuse dir.gc 1
LVDir Disks
lv_dir1 = ""
setwintitle Dir.gc 'Devices'
XBUTTON 205 39 14 13 A
GadID 104
lvuse dir.gc 1
LVDir all
XBUTTON 205 52 14 13 N
GadID 105
lvuse dir.gc 1
LVDir None
XBUTTON 205 65 14 15 F
GadID 106
lvuse dir.gc 1
lvmode MULTI
lvchange guis:tools/fav/DirDef
favmode.1 = 1
favid = 1
XBUTTON 205 177 14 12 + ; add to favourites
GadID 107
lvuse dir.gc 1
gosub dir.gc addfav
XBUTTON 205 189 14 13 R
GadID 108
lvuse dir.gc 1
lvdir Refresh
XBUTTON 205 202 14 13 < ; move list left
GadID 109
lvuse dir.gc 1
lvmove -10
XBUTTON 205 215 14 13 >
GadID 110
lvuse dir.gc 1
lvmove 10
;---------> for the right side (destination) give gadID so we set them on/off
XBUTTON 426 0 14 13 P
GadID 201
lvuse dir.gc 2
LVDir parent
setvar lv_dir2 $$LV.DIR
update Dir.gc 10 $$lv.dir
XBUTTON 426 13 14 13 R
gadid 202
lvuse dir.gc 2
LVDir Root
setvar lv_dir2 $$LV.DIR
update Dir.gc 10 $$lv.dir
XBUTTON 426 26 14 13 D
gadid 203
lvuse dir.gc 2
LVDir Disks
setvar lv_dir2 ""
update Dir.gc 10 ""
XBUTTON 426 39 14 13 A
gadid 204
lvuse dir.gc 2
LVDir All
XBUTTON 426 52 14 13 N
gadid 205
lvuse dir.gc 2
LVDir None
XBUTTON 426 65 14 15 F
gadid 206
lvuse dir.gc 2
lvmode MULTI
lvchange guis:tools/fav/DirDef
favmode.2 = 1
favid = 2
XBUTTON 426 178 14 11 + ; add to favourites
gadid 207
lvuse dir.gc 2
gosub dir.gc addfav
XBUTTON 426 189 14 13 R
gadid 208
lvuse dir.gc 2
lvdir Refresh
XBUTTON 426 202 14 13 < ; move list left
GadID 209
lvuse dir.gc 2
lvmove -10
XBUTTON 426 215 14 13 > ; move list right
GadID 210
lvuse dir.gc 2
lvmove 10
;---------> open full file manager
XBUTTON 205 108 14 11 >
gadid 11
if $fm_mode = 1
gosub Dir.gc OpenWindow
else
gosub Dir.gc CloseWindow
endif
;--------> button to switch left <-> right lvs
XBUTTON 205 119 14 11 x
gadid 12
lvuse dir.gc 1
tempdir1 = $$lv.dir
lvuse dir.gc 2
tempdir2 = $$lv.dir
lvdir #$tempdir1
lvuse dir.gc 1
lvdir #$tempdir2
setwintitle Dir.gc '$tempdir2' ; and their dir displays
update Dir.gc 10 $tempdir1
delvar tempdir#?
;--------> same directories
XBUTTON 205 130 14 11 =
gadid 13
if $$lv.gui == dir.gc ; check that the internal vars point to us
id = $$lv.id
dir = $$lv.dir
if $id = 1
lvuse dir.gc 2
lvdir #$dir
update Dir.gc 10 $dir
else
lvuse dir.gc 1
lvdir #$dir
setwintitle Dir.gc '$dir'
endif
endif
;---------> ROUTINES
xRoutine OpenWindow ; Routine to enlarge the window
fm_mode = 2
setgad Dir.gc 2 SHOW
setgad Dir.gc 201/210 SHOW
setgad Dir.gc 10 SHOW
changearg Dir.gc 11 4 <
changegad Dir.gc 0 -1 -1 440 229 ""
redraw Dir.gc
xRoutine CloseWindow ; make it small again
fm_mode = 1
setgad Dir.gc 2 HIDE
setgad Dir.gc 201/210 HIDE
setgad Dir.gc 10 HIDE
changegad Dir.gc 0 -1 -1 220 229 ""
changearg Dir.gc 11 4 >
redraw Dir.gc
xroutine addfav ; add a path to the favourites
; see first if path exists
favdir = $$lv.dir
cli 'guis:c/fsearch >env:.addfav guis:tools/fav/DirDef txt=$favdir'
if $.addfav > " "
; path already exists
else
; get dir name as identifier name
extract favdir file favname
; append entry to the favourites file
append guis:tools/fav/DirDef '\n$favname\t\t\t\t$favdir'
endif
delvar .addfav
RESIZE_BIG 114 11 267 250 DIR.GC